// pages/enterprise/user/status/index.js
import Config from "../../../main.config"
import {getStorageSync} from "../../../utils/Storage"
import {getRegisterDetail} from "../../../service/Enterprise";
import {getUserInfo} from "../../../service/Common";
Page({

    /**
     * 页面的初始数据
     */
    data: {
        status: 0,
        remark: ""
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {

    },

    onShow: function () {
        this.getCompanyDetail()
    },

    /*
    * 获取企业详情
    * */
    getCompanyDetail: async function () {
        try {
            let openId = getStorageSync(Config.storage.openId);
            let userInfo = await getUserInfo(openId);
            let detail = await getRegisterDetail({createUser: userInfo.userId});
            if (!detail) {return false};
            this.setData({
                status: detail.status,
                remark: detail.remark
            })
            if (detail.status === 2) { //通过审核
                wx.redirectTo({
                    url: "/pages/index/index"
                })
            }
        } catch (e) {
            console.error(e)
        }
    },

    /*
    * 跳转
    * */
    bindNavigatorTo: function () {
        wx.redirectTo({url: "/packageEnterprise/pages/info/index"})
    }
})